#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments.  The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".

bash gradlew verifyGoogleJavaFormat
result=$?
printf "the verifyGoogleJavaFormat result code is $result"
if [[ "$result" = 0 ]] ; then
    echo "\033[32m
    ....
    ....
    verifyGoogleJavaFormat Pass!!
    ....
    ....
    \033[0m"
    exit 0
else
    bash gradlew goJF
    echo "\033[31m
    ....
    ....
    verifyGoogleJavaFormat Failed!!
    Code format has been automatically adjusted, please review the code and then git add. && git commit;
    ....
    ....
    \033[0m"
    exit 1
fi